home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / gui / MultiDesktop.lha / MultiDesktop / font.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-27  |  978 b   |  55 lines

  1. #include <exec/types.h>
  2. #include <graphics/rastport.h>
  3. #include <graphics/text.h>
  4. #include <libraries/diskfont.h>
  5.  
  6. APTR DiskfontBase;
  7. APTR GfxBase;
  8.  
  9. struct RastPort *rp,xrp;
  10. struct TextAttr  attr={0L,0,FS_NORMAL,FPF_DISKFONT};
  11. struct TextFont *font;
  12.  
  13. UBYTE *TestText="abcdefghijklmnopqrstuvwxyz  -  1234567890 #,.;:*+^/*?!|$%&()= <> ABCDEFGHIJKLMNOPQRSTUVWXYZ öäüÄÖÜß";
  14.  
  15. void main(argc,argv)
  16.  int argc;
  17.  UBYTE *argv[];
  18. {
  19.  long i,j;
  20.  
  21.  if(argc!=3)
  22.   {
  23.    puts("Usage: Font [name] [size]");
  24.    exit(0);
  25.   }
  26.  
  27.  GfxBase=OpenLibrary("graphics.library",0L);
  28.  DiskfontBase=OpenLibrary("diskfont.library",0L);
  29.  
  30.  rp=&xrp;
  31.  InitRastPort(rp);
  32.  
  33.  attr.ta_Name=argv[1];
  34.  attr.ta_YSize=atol(argv[2]);
  35.  
  36.  font=OpenDiskFont(&attr);
  37.  if(font!=NULL)
  38.   {
  39.    SetFont(rp,font);
  40.  
  41.    i=TextLength(rp,TestText,strlen(TestText));
  42.    printf("H=%5ld\nV=%5ld\n",i,font->tf_YSize);
  43.  
  44.    CloseFont(font);
  45.   }
  46.  else
  47.   {
  48.    puts("Unable to open font!");
  49.   }
  50.  
  51.  CloseLibrary(DiskfontBase);
  52.  CloseLibrary(GfxBase);
  53. }
  54.  
  55.